package com.gugee.ins.common.dal.mapper.statistics;

import com.gugee.common.mapper.GugeeMapper;
import com.gugee.ins.common.model.es.brand.InsBrandEsMapping;
import com.gugee.ins.common.model.mysql.statistics.InsStBrand;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;


/**
 * InsBrandMapper
 * @author huangxin
 */
public interface InsStBrandMapper extends GugeeMapper<InsStBrand> {
    /**
     * 更新打点
     * @param bid
     * @param limitTimeStart
     * @param limitTimeEnd
     * @param nowTime
     */
    void updateBrandSt(@Param("bid")long bid,@Param("limitTimeStart") long limitTimeStart,
                       @Param("limitTimeEnd") long limitTimeEnd,@Param("nowTime") long nowTime);

    /**
     * 判断是否存在
     * @param bid
     * @return
     */
    @Select("select 1 from ins_st_brand where bid = #{bid} ")
    Integer findExist(@Param("bid")long bid);

    /**
     * 插入初始化的空数据
     * @param bid
     * @param nowTime
     */
    void insertEmptyData(@Param("bid")long bid,@Param("nowTime")long nowTime);

    /**
     * 查询品牌详情信息
     * @param bid
     * @return
     */
    @Select("select c.id,alias,c.brand_name,c.category_name,c.checked,c.en_name," +
            " b.tec engagements,c.last_analysis_category_time,b.last_st_time," +
            "b.like_count likes,c.logo,media_count,c.parent_id,c.reviewed,b.review_count reviews " +
            "from common_brand c LEFT JOIN ins_st_brand b on c.id = b.bid where c.id = #{bid} ")
    InsBrandEsMapping findEsMappingByBid(@Param("bid") long bid);
}